package com.longteng.diamond.dao;

import com.longteng.diamond.domain.ProjectShareNode;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator
 * DATE : 2018/7/23
 * TIME : 22:18
 * PROJECT : java-lesson
 * PACKAGE : com.longteng.lesson
 *
 * @author <a href="mailto:taki@qq.com">Administrator</a>
 */
@Mapper
public interface ProjectMemberMapper extends BaseMapper {
    /**
     * 查询项目成员
     * @param projectShareNode
     * @return
     */
    @Override
    List<ProjectShareNode> getProjectShareNode(ProjectShareNode projectShareNode);
    @Select("select count(*) from project_member where yn =1  and  projectId=#{projectId}")
    /**
     * 查询host、模块、项目成员所有行数
     * @param projectShareNode
     * @return
     */
    @Override
    long queryAllRow(ProjectShareNode projectShareNode);
    @Select("select * from project_member where id=#{id}")
    /**
     * 根据id查询项目成员
     * @param id
     * @return
     */
    @Override
    ProjectShareNode findProjectShareNodeById(Integer id);
    @Insert("insert into project_member(userId,projectId,createTime,updateTime,yn) " +
            "values(#{userId},#{projectId},now(),now(),1)")
    void addProjectShareNode(ProjectShareNode projectShareNode);
    @Update("update project_member set userId =#{userId},updateTime=now() where id =#{id}")
    void updateProjectShareNode(ProjectShareNode projectShareNode);
    @Delete("update project_member set yn =0,updateTime=now() where id =#{id}")
    void deleteProjectShareNode(Integer id);
}
